<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%@ include file="/common/grid/jqGrid.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="">
	<meta http-equiv="description" content="">
	
  </head>
  
  <body>
  	<center>
    	<s:form name="frm" id="frm" method="post" action="" namespace="">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'保存表单定义'}]"/>
    			<jsp:param name="width" value="70%"/>
    		</jsp:include>
    		
    		
    		<s:hidden id="formId" name="fd.id"></s:hidden>
    		<s:hidden id="moduleId" name="fd.formModule.id"></s:hidden>
    		
    		<table width="98%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr bgcolor="#FFFFFF">
    				<td width="10%" align="right" class="label">
    					表单编码：
    				</td>
    				<td width="30%" align="left">
    					<s:textfield name="fd.formCode" id="formCode" cssStyle="width:200px" maxlength="20"></s:textfield>
    				</td>
    				<td width="10%" align="right" class="label">
    					表单名称：
    				</td>
    				<td width="30%" align="left">
    					<s:textfield name="fd.formName" id="formName" cssStyle="width:200px" maxlength="20"></s:textfield>
    				</td>
    				<td width="20%" rowspan="2" align="center" valign="top">
    					<table cellpadding="3" width="200px">
    						<tr>
    							<td width="100%" align="left">
    								<input type="button" value="新增" class="btn" onclick="addFormModule()" /><br/>
    								命名空间：
    								<input type="text" name="namespace" class="pass" style="width:100px" />
    								<input type="button" value="查询" class="btn" onclick="searchThis()" />
    							</td>
    						</tr>
    						<tr>
    							<td align="center">
    								<table id="listGrid" cellpadding="3" cellspacing="0"></table>
    								<div id="pager" style="text-align:center;"></div>
    							</td>
    						</tr>
    					</table>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					表单内容：
    				</td>
    				<td align="left" colspan="3">
    					<s:textarea name="fd.formContentStr" id="formContent" cssStyle="width:99%; height:600px"></s:textarea>
    				</td>
    			</tr>
    		</table>
    		
    		<table width="100%" cellspacing="0">
    			<tr>
    				<td align="center" valign="bottom" height="30">
    					<input type="button" value="保存" class="btn" onclick="saveFormDefine()" />
    					<input type="button" value="返回" class="btn" onclick="returnBack()" />
    				</td>
    			</tr>
    		</table>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    $(function(){
		loadGridData('listGrid', 'pager', 'frm');
	});

    function searchThis()
    {
    	toSearchList('listGrid', 'frm');
    }
	
    function saveFormDefine()
    {
        var formCode = $('#formCode');
        var formName = $('#formName');
        if(!isNotNull(formCode.val()))
        {
			showMsg('表单编码不能为空。', function(){
				formCode.focus();
			});
			return;
        }
        if(formCode.val().indexOf('_') > -1)
        {
			showMsg('表单编码不能有“_”。', function(){
				formCode.focus();
			});
			return;
        }
        if(!isNotNull(formName.val()))
        {
			showMsg('表单名称不能为空。', function(){
				formName.focus();
			});
			return;
        }
		var url = 'inner/core/saveFormDefine.action';
		ajaxAction(url, 'post', 'frm', true, function(msg){
			var obj = eval(msg);
			if('success' == obj.result)
			{
				
			}
			else
			{
				showMsg(obj.message);
			}
		});
    }

    function returnBack()
    {
        var moduleId = $('#moduleId');
		var url = realPath + '/inner/core/formDefineManage.action?lvvo.listCode=form_formDefine&fvo.moduleId=' + moduleId.val();
		window.location.href = url;
    }
    </script>
  </body>
</html>
